package stackTriangle2;

import java.util.Scanner;

/**
 * Created by hps on 17-5-1.
 */
public class StackTriangle2App {
    static int theNumber;
    static int theAnswer;
    static StackX theStack;

    public static void main(String[] args) {
        System.out.print("Enter a number: ");
        Scanner scanner = new Scanner(System.in);
        theNumber = scanner.nextInt();
        stackTriangle();
        System.out.println("Triangle = " + theAnswer);
    }

    public static void stackTriangle() {
        theStack = new StackX(10000);
        theAnswer = 0;
        while (theNumber > 0) {
            theStack.push(theNumber--);
        }

        while (!theStack.isEmpty())
            theAnswer += theStack.pop();
    }
}
